package dto;

import org.jdom.Element;

/**
 *
 * @author Jose Carlos Gutierrez
 */
public class Avion{

    private int id;
    private String codigoAvion;
    private double performance;
    private double capacidadCombustible;
    private double velocidadPromedio;
    private int idConcurrencia;

    public Avion(){
        this.id = 0;
        this.codigoAvion = "";
        this.performance = this.capacidadCombustible =
                this.velocidadPromedio = 0;
        this.idConcurrencia = 1;
    }

    public double getCapacidadCombustible() {
        return capacidadCombustible;
    }

    public void setCapacidadCombustible(double capacidadCombustible) {
        this.capacidadCombustible = capacidadCombustible;
    }

    public String getCodigoAvion() {
        return codigoAvion;
    }

    public void setCodigoAvion(String codigoAvion) {
        this.codigoAvion = codigoAvion;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getIdConcurrencia() {
        return idConcurrencia;
    }

    public void setIdConcurrencia(int idConcurrencia) {
        this.idConcurrencia = idConcurrencia;
    }

    public double getPerformance() {
        return performance;
    }

    public void setPerformance(double performance) {
        this.performance = performance;
    }

    public double getVelocidadPromedio() {
        return velocidadPromedio;
    }

    public void setVelocidadPromedio(double velocidadPromedio) {
        this.velocidadPromedio = velocidadPromedio;
    }

    public Element toXml() {
        Element root = new Element("dato");

        Element child = new Element("id");
        child.setText(Integer.toString(this.id));
        root.addContent(child);

        child = new Element("nombre");
        child.setText(this.codigoAvion);
        root.addContent(child);

        child = new Element("performance");
        child.setText(Double.toString(performance));
        root.addContent(child);

        child = new Element("capacidad-combustible");
        child.setText(Double.toString(capacidadCombustible));
        root.addContent(child);

        child = new Element("velocidad-promedio");
        child.setText(Double.toString(velocidadPromedio));
        root.addContent(child);

        child = new Element("id-concurrencia");
        child.setText(Integer.toString(this.idConcurrencia));
        root.addContent(child);

        return root;
    }

    public double getCosto() {
        return 60.0/velocidadPromedio;
    }
}
